package licode.unisop.oidc.auth.modal;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;

/**
 * 定义授权的参数请求
 *
 * @author licode
 */
@Data
@Builder
@AllArgsConstructor
public class AuthorRequest implements Serializable {

	private static final long serialVersionUID = -6521190061682008125L;

	/**
	 * 单点登录的会话令牌
	 */
	private String ssoToken;

	/**
	 * 应用id
	 */
	private String clientId;
	private String clientSecret;

	/**
	 * 授权范围
	 */
	private String scope;

	/**
	 * 授权码值
	 */
	private String code;

	/**
	 * 待重定向URL（授权码登录的时候用到）
	 */
	private String redirectUri;
	
	/**
	 * 授权类型, 非必填，默认password
	 */
	private String grantType;

	/**
	 * 状态标识, 可为null
	 */
	private String state;

	/**
	 * 授权模式（sso：单点登录；normal：普通登录）
	 */
	private String authMode;

	/**
	 * 定义扩展信息
	 */
	private String params;

	/**
	 * 认证的上下文信息
	 */
	private AuthorContext context;

	public AuthorRequest() {
		context = new AuthorContext();
	}

	public void setSsoToken(String ssoToken) {
		this.ssoToken = ssoToken;
	}

	/**
	 * @param clientId 要设置的 clientId
	 * @return 对象自身
	 */
	public AuthorRequest setClientId(String clientId) {
		this.clientId = clientId;
		return this;
	}

	public void setClientSecret(String clientSecret) {
		this.clientSecret = clientSecret;
	}

	/**
	 * @param scope 要设置的 scope
	 * @return 对象自身
	 */
	public AuthorRequest setScope(String scope) {
		this.scope = scope;
		return this;
	}

	public void setCode(String code) {
		this.code = code;
	}

	/**
	 * @param redirectUri 要设置的 redirectUri
	 * @return 对象自身
	 */
	public AuthorRequest setRedirectUri(String redirectUri) {
		this.redirectUri = redirectUri;
		return this;
	}

	/**
	 * @param grantType 要设置的 grantType
	 * @return 对象自身
	 */
	public AuthorRequest setGrantType(String grantType) {
		this.grantType = grantType;
		return this;
	}

	/**
	 * @param state 要设置的 state
	 * @return 对象自身
	 */
	public AuthorRequest setState(String state) {
		this.state = state;
		return this;
	}

	public void setAuthMode(String authMode) {
		this.authMode = authMode;
	}

	public void setParams(String params) {
		this.params = params;
	}

	public void setContext(AuthorContext context) {
		this.context = context;
	}
}
